<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.changziming.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: changziming.com 
// +----------------------------------------------------------------------

if(version_compare(PHP_VERSION,'5.3.0','<'))  die('require PHP > 5.3.0 !');

/**
 * 系统调试设置
 * 项目正式部署后请设置为false
 */
define('APP_DEBUG', true );

/**
 * 应用目录设置
 * 安全期间，建议安装调试完成后移动到非WEB目录
 */
define ( 'APP_PATH', './Application/' );

/**
 * 缓存目录设置
 * 此目录必须可写，建议移动到非WEB目录
 */
define ( 'RUNTIME_PATH', './Runtime/' );

/**
 * 模拟json中文不转义
 */
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
    function json_encode_ex($var) {
        return json_encode($var, JSON_UNESCAPED_UNICODE);
    }
} else {
    function json_encode_ex($var) {
        if ($var === null)
            return 'null';
        if ($var === true)
            return 'true';
        if ($var === false)
            return 'false';
        static $reps = array(
            array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"', ),
            array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"', ),
        );
        if (is_scalar($var))
            return '"' . str_replace($reps[0], $reps[1], (string) $var) . '"';
        if (!is_array($var))
            throw new Exception('JSON encoder error!');
        $isMap = false;
        $i = 0;
        foreach (array_keys($var) as $k) {
            if (!is_int($k) || $i++ != $k) {
                $isMap = true;
                break;
            }
        }
        $s = array();
        if ($isMap) {
            foreach ($var as $k => $v)
                $s[] = '"' . $k . '":' . call_user_func(__FUNCTION__, $v);
            return '{' . implode(',', $s) . '}';
        } else {
            foreach ($var as $v)
                $s[] = call_user_func(__FUNCTION__, $v);
            return '[' . implode(',', $s) . ']';
        }
    }
}
/**
 * 引入核心入口
 * ThinkPHP亦可移动到WEB以外的目录
 */
require './ThinkPHP/ThinkPHP.php';